package com.mallcloud.mall.mall.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.mallcloud.mall.app.service.AppOrderCouponService;
import com.mallcloud.mall.mall.api.entity.MallOrderCouponModel;
import com.mallcloud.mall.mall.api.entity.vo.MallOrderCouponVO;
import com.mallcloud.mall.mall.mapper.MallOrderCouponMapper;
import com.mallcloud.mall.mall.service.MallOrderCouponService;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import java.util.Collections;
import java.util.List;
import java.util.Objects;

/**
 * 券订单
 */
@Slf4j
@Service
@AllArgsConstructor
public class MallOrderCouponServiceImpl extends ServiceImpl<MallOrderCouponMapper, MallOrderCouponModel> implements MallOrderCouponService {

	private final AppOrderCouponService appOrderCouponService;

	@Override
	public Boolean compensate(List<Long> ids) {
		return appOrderCouponService.compensate(ids);
	}

	@Override
	public Page pageOrderCoupon(Page<MallOrderCouponVO> page, MallOrderCouponModel dto) {
		return this.baseMapper.pageOrderCoupon(page, dto);
	}

	@Override
	public List<MallOrderCouponVO> listOrderCoupon(MallOrderCouponModel dto) {
		return this.baseMapper.pageOrderCoupon(dto);
	}

	@Override
	public List<MallOrderCouponVO> listByOrderNos(List<String> orderNos) {
		if(Objects.isNull(orderNos) && orderNos.isEmpty()){
			return Collections.emptyList();
		}
		return this.baseMapper.listByOrderNos(orderNos);
	}
}
